﻿using System;
using System.IO;

//using System.Windows.Forms;

namespace Hostblock_helper
{
    internal static class Helper
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            bool x64 = Environment.Is64BitOperatingSystem;
            string HostsPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\drivers\etc\hosts";
            string HostPathWoW = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + @"\drivers\etc\hosts";
            string HostsQuelle = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) + @"\hosts";
            string rv = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) + @"\Hostblock";
            try
            {
                File.Copy(HostsQuelle, HostsPath, true);
                if (x64)
                {
                    File.Copy(HostsQuelle, HostPathWoW, true);
                }
                File.WriteAllText(rv, "SUCCESS");
            }
            catch (Exception ex)
            {
                File.WriteAllText(rv, ex.Message.ToString());
            }
            finally
            {
                File.Delete(HostsQuelle);
            }
        }
    }
}